<template>
    <div class="admin_post_index">
        <div class="row">
            <div class="col-xs-12">
                <data-table
                    class="box"
                    :class="'box-' + theme"
                    :options="options"
                    ref="table"
                >
                <template slot="col-operation" slot-scope="props">
                    <button v-show="props.data.configUrl['deleteUrl']"
                            :title="$t('Delete selected')"
                            type="button"
                            class="btn btn-danger btn-xs"
                            :disabled="props.row[options.primaryKey]==1"
                            @click="props.remove([props.row[options.primaryKey]])">
                        <i class="fa fa-trash-o"></i>
                    </button>
                     
                </template>

                <template slot="col-checkbox" slot-scope="props">
                    <icheck v-model="props.check_ids"
                            class="ids"
                            :disabled-label="true"
                            :disabled="props.row[options.primaryKey]==1"
                            :option="props.row[options.primaryKey]"></icheck>
                </template>

                </data-table>
            </div>
        </div>
    </div>
</template>

<script>
import { mapState, mapActions, mapMutations, mapGetters } from "vuex";
export default {
    components: {
        "data-table": () =>
            import("common_components/datatable.vue"),
        "icheck":()=>import('common_components/icheck.vue'),
    },
    props: {},
    data() {
        let def_options = JSON.parse(this.$router.currentRoute.query.options || '{}');
        return {
            options: {
                lang_table: "posts", //字段翻译
                id: "data-table", //多个data-table同时使用时唯一标识
                url: "", //数据表请求数据地址
                operation: true, //操作列
                checkbox: true, //选择列
                btnSizerMore: true, //更多筛选条件按钮
                keywordKey: "keyword|title", //关键字查询key
                keywordGroup: false, //是否为选项组
                keywordPlaceholder: () => {
                    return this.$t("Please enter keywords");
                },
                primaryKey: "id", //数据唯一性主键
                defOptions:def_options, //默认筛选条件
                fields: {
                    id: { name: "ID", order: true },
                    keyword: { name: "keyword", order: true },
                    client_ip:{ name: "client_ip", order: true },
                    // title: { name: "title" },
                    // sort: { name: "sort", order: true },
                    // short_article: { name: "short_article" },
                    created_at: {name: "Created At",order: true,type: "time"},
                    updated_at: {name: "Updated At",order: true,type: "time"},
                },
            },
        };
    },
    computed: {
        ...mapState(["use_url", "theme"]),
    },
    methods: {},
};
</script>
<style lang="scss" scoped></style>
